{% load crispy_forms_field unfold %}

{% if field.is_hidden %}
    {{ field }}
{% else %}
    <{% if tag %}{{ tag }}{% else %}div{% endif %} id="div_{{ field.auto_id }}" class="group {% if tag == "td" %}align-top border-t border-base-200 font-normal gap-4 min-w-0 overflow-hidden px-3 py-3 text-left dark:border-base-800 dark:before:text-font-important-dark {% if form_show_labels and forloop.parentloop.first %}border-t-0{% endif %}{% endif %} {% if field.errors %}errors{% endif %} {% if field_class %} {{ field_class }}{% endif %} {% if field|is_checkbox and tag == "td" %}flex flex-row gap-2 items-center{% else %} {% if 'form-horizontal' in form_class %} border-b border-base-200 border-dashed flex flex-col -mx-3 px-3 py-2.5 lg:flex-row last:-mb-3 dark:border-base-800 last:border-b-0 {% endif %}{% endif %}{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">
    {% if field.label and not field|is_checkbox and form_show_labels %}
        <label {% if field.id_for_label %}for="{{ field.id_for_label }}"{% endif %} class="block font-semibold text-font-important-light dark:text-font-important-dark {% if 'form-horizontal' in form_class %}mb-2 lg:mb-0 lg:min-w-56 {% if not field|is_checkbox and not field|is_radioselect and not field|is_checkboxselectmultiple %}lg:mt-2{% endif %} lg:w-56{% else %}mb-2{% endif %} {% if label_class %} {{ label_class }}{% endif %}">
            {{ field.label }}{% if field.field.required %} <span class="asteriskField">*</span>{% endif %}
        </label>
    {% endif %}

    <div class="grow">
        {% if field|is_checkboxselectmultiple or field|is_radioselect %}
            {% include 'unfold_crispy/layout/radio_checkbox_select.html' %}
        {% elif field|is_checkbox  %}
            {% include 'unfold_crispy/layout/checkbox.html' %}
        {% else %}
            {% crispy_field field %}

            {% include 'unfold_crispy/layout/help_text_and_errors.html' %}
        {% endif %}
    </div>
    </{% if tag %}{{ tag }}{% else %}div{% endif %}>
{% endif %}
